import network from '@system.network'
import wifi from '@system.wifi'

const getNetwork = () => {
  return new Promise(resolve => {
    try {
      network.getType({
        success: resolve,
        fail(e) {
          console.error(e)
          resolve({})
        }
      })
    } catch (e) {
      console.error(e)
      resolve({})
    }
  })
}
const getWifi = () => {
  return new Promise(resolve => {
    try {
      wifi.getConnectedWifi({
        success: resolve,
        fail(e) {
          console.error(e)
          resolve({})
        }
      })
    } catch (e) {
      console.error(e)
      resolve({})
    }
  })
}
const getOperators = () => {
  return new Promise(resolve => {
    try {
      network.getSimOperators({
        success: resolve,
        fail(e) {
          console.error(e)
          resolve({})
        }
      })
    } catch (e) {
      console.error(e)
      resolve({})
    }
  })
}
export default () => {
  return new Promise(resolve => {
    Promise.all([getNetwork()]).then(response => {
      resolve(response)
    })
  })
}
